import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:znmm/UI/utils/sharedpre_utils.dart';

import '../strings.dart';

part 'app_mode_state.dart';

//系统模式暗黑模式 System Mode  / Dark Mode 等
class AppModeCubit extends Cubit<AppModeState> {
  AppModeCubit(String mode) : super(AppModeInitial(mode)) {
    loadMode();
  }

  void loadMode() {
    String? selectedMode = SharedPrefUtil().getData(SharedKey.strModeKey);
    //print("selectedMode2:$selectedMode");
    emit(AppModeUpdate(selectedMode ?? c_systemStr));
  }

  void changeMode(String value) {
    SharedPrefUtil().setData(SharedKey.strModeKey, value);

    emit(AppModeUpdate(value));
  }
}
